package main

import (
	"fmt"
	"helloworld/model"
)

type Student4 struct {
	Name  string
	Age   int
	Score float64
}

func (stu *Student4) ShowInfo() {
	fmt.Printf("学生姓名：%v, 年龄：%v, 分数:%v \n", stu.Name, stu.Age, stu.Score)
}

func (stu *Student4) SetScore(score float64) {
	stu.Score = score
}

type Pupil struct {
	Student4 //嵌入了匿名结构体，说明是继承了
}

func (pupil *Pupil) testing() {
	fmt.Println("小学生正在考试中")
}

type Graduate struct {
	Student4
}

func (graduate *Graduate) testing() {
	fmt.Println("大学生正在考试中")
}

type Goods struct {
	name  string
	price float64
}
type Brand struct {
	name    string
	address string
}

type TV struct {
	Goods
	Brand
}
type TV2 struct {
	*Goods
	*Brand
}

func main() {
	person1 := model.NewPerson1("张三")
	person1.SetAge(12)
	person1.SetSal(99.5)
	fmt.Println(person1, person1.GetAge(), person1.GetSal())
	fmt.Println("=======")

	p := new(Pupil)
	p.Student4.Name = "张三"
	p.Student4.Age = 12
	p.Student4.SetScore(99)
	p.Student4.ShowInfo()

	//简写
	p.Name = "张三"
	p.Age = 12
	p.SetScore(99)
	p.ShowInfo()
	p.testing()
	fmt.Println("=======")

	g := new(Graduate)
	g.Student4.Name = "李四"
	g.Student4.Age = 13
	g.Student4.SetScore(99.9)
	g.Student4.ShowInfo()
	g.testing()

	fmt.Println("==============")
	tv := TV{Goods{"电视", 1000.90}, Brand{"小米", "北京"}}
	tv2 := TV{
		Goods{
			"电视",
			1000.90,
		},
		Brand{"小米",
			"北京",
		},
	}
	fmt.Println("tv", tv)
	fmt.Println("tv2", tv2)

	fmt.Println("==============")
	tv3 := TV2{&Goods{"电视", 1000.90}, &Brand{"小米", "北京"}}
	tv4 := TV2{
		&Goods{
			"电视",
			1000.90,
		},
		&Brand{"小米",
			"北京",
		},
	}
	fmt.Println("tv3", tv3)
	fmt.Println("tv4", tv4)

}
